﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _03_TryCatch
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int a = 10;
            int b = 1;

            try
            { 
                int c = a/b + int.Parse("3.DF");
                //打印式子与计算结果
                Console.WriteLine("{0}/{1}={2}", a, b, c);
            }
            catch (DivideByZeroException ex)//捕获除零异常(只捕获指定的异常)
            {
                Console.WriteLine("除零异常！");
            }
            catch (Exception ex)//捕获异常，然后提示异常信息
            {
                Console.WriteLine(ex);
            }
            finally//无论是否发生异常，都会执行
            {
                Console.WriteLine("程序执行完毕！");
            }

            Console.Read();
        }
    }
}
